﻿<local:CrosswordWindowBase
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Corss_LehaKondr" xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Corss_LehaKondr.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <local:CrosswordWindowBase.Resources>
        <SolidColorBrush x:Key="CheckBoxStroke" Color="#8E8F8F"/>
        <Style x:Key="CheckRadioFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Margin="14,0,0,0" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <SolidColorBrush x:Key="LayoutRadioHoverBackground" Color="#FFECEFFF"/>
        <SolidColorBrush x:Key="LayoutRadioPressedBackground" Color="#FFDDDFF1"/>
        <Style x:Key="LayoutRadio" TargetType="{x:Type RadioButton}">
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RadioButton}">
                        <!--<BulletDecorator Background="Transparent">
                            <BulletDecorator.Bullet>
                                <Themes:BulletChrome BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" IsChecked="{TemplateBinding IsChecked}" IsRound="true" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}"/>
                            </BulletDecorator.Bullet>
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </BulletDecorator>-->
                        <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Background" TargetName="border" Value="{DynamicResource LayoutRadioPressedBackground}"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" TargetName="border" Value="{DynamicResource LayoutRadioHoverBackground}"/>
                            </Trigger>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter Property="Background" TargetName="border" Value="{DynamicResource LayoutRadioPressedBackground}"/>
                            </Trigger>
                            <Trigger Property="HasContent" Value="true">
                                <Setter Property="FocusVisualStyle" Value="{StaticResource CheckRadioFocusVisual}"/>
                                <Setter Property="Padding" Value="5"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Background" Value="White"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        </Style>
        <Storyboard x:Key="OnChecked1">
            <!--<Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="scrollViewer">
        		<EasingInt32KeyFrame KeyTime="0" Value="0"/>
        	</Int32AnimationUsingKeyFrames>
        	<Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="scrollViewer">
        		<EasingInt32KeyFrame KeyTime="0" Value="0"/>
        	</Int32AnimationUsingKeyFrames>-->
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.RowSpan)" Storyboard.TargetName="crossCellScroll">
                <EasingInt32KeyFrame KeyTime="0" Value="1"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.ColumnSpan)" Storyboard.TargetName="crossCellScroll">
                <EasingInt32KeyFrame KeyTime="0" Value="3"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="0"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.RowSpan)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="1"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.ColumnSpan)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="3"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="2"/>
            </Int32AnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="horizontalSplitter">
                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="verticalSplitter">
                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
            </ObjectAnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(UniformGrid.Columns)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="2"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(UniformGrid.Rows)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="1"/>
            </Int32AnimationUsingKeyFrames>
            <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(StackPanel.Orientation)" Storyboard.TargetName="asksBlockStack">
                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Orientation.Horizontal}"/>
            </ObjectAnimationUsingKeyFrames>-->
        </Storyboard>
        <Storyboard x:Key="OnChecked2">
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.ColumnSpan)" Storyboard.TargetName="crossCellScroll">
                <EasingInt32KeyFrame KeyTime="0" Value="1"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.RowSpan)" Storyboard.TargetName="crossCellScroll">
                <EasingInt32KeyFrame KeyTime="0" Value="3"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="0"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="2"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.ColumnSpan)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="1"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.RowSpan)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="3"/>
            </Int32AnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="horizontalSplitter">
                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="verticalSplitter">
                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(UniformGrid.Rows)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="2"/>
            </Int32AnimationUsingKeyFrames>
            <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(UniformGrid.Columns)" Storyboard.TargetName="asksBlockGrid">
                <EasingInt32KeyFrame KeyTime="0" Value="1"/>
            </Int32AnimationUsingKeyFrames>
            <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(StackPanel.Orientation)" Storyboard.TargetName="asksBlockStack">
                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Orientation.Vertical}"/>
            </ObjectAnimationUsingKeyFrames>-->
            <!--<Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="scrollViewer">
        		<EasingInt32KeyFrame KeyTime="0" Value="0"/>
        	</Int32AnimationUsingKeyFrames>
        	<Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="scrollViewer">
        		<EasingInt32KeyFrame KeyTime="0" Value="0"/>
        	</Int32AnimationUsingKeyFrames>-->
        </Storyboard>
    </local:CrosswordWindowBase.Resources>
    <local:CrosswordWindowBase.Triggers>
        <EventTrigger RoutedEvent="ToggleButton.Checked" SourceName="horizontalLayoutButton">
            <BeginStoryboard Storyboard="{StaticResource OnChecked1}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ToggleButton.Checked" SourceName="verticalLayoutButton">
            <BeginStoryboard x:Name="OnChecked2_BeginStoryboard" Storyboard="{StaticResource OnChecked2}"/>
        </EventTrigger>
    </local:CrosswordWindowBase.Triggers>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="5"/>
            <ColumnDefinition/>
            <ColumnDefinition Width="5"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="20"/>
            <RowDefinition/>
            <RowDefinition Height="5"/>
        </Grid.RowDefinitions>
        <Menu Grid.ColumnSpan="3" >
            <MenuItem Header="Menu"/>
        </Menu>
        <Grid Grid.Column="1" Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Строк: " />
                    <TextBlock Text="{Binding VerticalCells, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}, StringFormat=\{0:D\}}" />
                    <Button Command="local:CrosswordWindowBase.incVCell" Content="+"/>
                    <Button Command="local:CrosswordWindowBase.decVCell" Content="-"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Столбцов: " />
                    <TextBlock Text="{Binding HorizontalCells, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}, StringFormat=\{0:D\}}" />
                    <Button Command="local:CrosswordWindowBase.incHCell" Content="+"/>
                    <Button Command="local:CrosswordWindowBase.decHCell" Content="-"/>
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="1">
                <!--<Button x:Name="horizontalLayoutButton" Content="Button" Margin="5,0,0,0"/>
            <Button x:Name="verticalLayoutButton" Content="Button" Margin="{Binding Margin, ElementName=horizontalLayoutButton}"/>-->
                <RadioButton x:Name="horizontalLayoutButton"  Margin="5,0,0,0" Style="{DynamicResource LayoutRadio}" Width="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" Foreground="#FF535353" IsChecked="True" GroupName="layoutSwitch">
                    <UniformGrid Rows="2">
                        <Border BorderThickness="1" BorderBrush="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RadioButton}}}">
                            <Rectangle Fill="White"/>
                        </Border>
                        <Rectangle Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RadioButton}}}"/>
                    </UniformGrid>
                </RadioButton>
                <RadioButton x:Name="verticalLayoutButton" Margin="{Binding Margin, ElementName=horizontalLayoutButton}" Style="{DynamicResource LayoutRadio}" Width="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" Foreground="{Binding Foreground, ElementName=horizontalLayoutButton}" GroupName="{Binding GroupName, ElementName=horizontalLayoutButton}">
                    <UniformGrid Columns="2">
                        <Border BorderThickness="1" BorderBrush="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RadioButton}}}">
                            <Rectangle Fill="White"/>
                        </Border>
                        <Rectangle Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RadioButton}}}"/>
                    </UniformGrid>
                </RadioButton>
            </StackPanel>
        </Grid>
        <Grid x:Name="uniformGrid" Grid.Row="2" Grid.Column="1" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <ScrollViewer x:Name="crossCellScroll" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Grid.ColumnSpan="3">
                <Border BorderBrush="{DynamicResource CorssCellBorder}" BorderThickness="1,0,1,1" VerticalAlignment="Top" HorizontalAlignment="Left">
                    <UniformGrid x:Name="cellsGrid" Columns="{Binding HorizontalCells, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" Rows="{Binding VerticalCells, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}">
                        <!--<local:Cell Text="а" isAnswerStart="True"/>
                <local:Cell isUsable="False"/>
                <local:Cell isUsable="False" ShowInsertMask="True"/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>



                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>


                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>


                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>


                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>


                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>


                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>


                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>


                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>


                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>
                <local:Cell/>-->
                    </UniformGrid>
                </Border>
            </ScrollViewer>
            <UniformGrid x:Name="asksBlockGrid" Grid.Row="2" Grid.ColumnSpan="3" Rows="1" Columns="2" >
                <Grid Margin="5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.ColumnSpan="2" Text="По горизонтале:" />
                    <ListBox Grid.Row="1" ItemsSource="{Binding hAsks, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" ItemTemplate="{DynamicResource AskDataTemplate}" SelectedIndex="{Binding SelectedHAskIndex, Mode=OneWayToSource, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}"/>
                    <StackPanel Grid.Column="1" Grid.Row="1" Width="72" Margin="5,0,0,0">
                        <Button Content="{Binding Command.Text, RelativeSource={RelativeSource Self}}" Command="local:CrosswordWindowBase.AddHAsk" />
                        <Button Content="{Binding Command.Text, RelativeSource={RelativeSource Self}}" Command="local:CrosswordWindowBase.ChangeHAsk" />
                        <Button Content="{Binding Command.Text, RelativeSource={RelativeSource Self}}" Command="local:CrosswordWindowBase.RemoveHAsk"/>
                    </StackPanel>
                </Grid>
                <Grid Margin="5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.ColumnSpan="2" Text="По вертикале:" />
                    <ListBox Grid.Row="1" ItemsSource="{Binding vAsks, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" ItemTemplate="{DynamicResource AskDataTemplate}"/>
                    <StackPanel Grid.Column="1" Grid.Row="1" Width="72" Margin="5,0,0,0">
                        <Button Content="Добавить" />
                        <Button Content="Изменить" />
                        <Button Content="Удалить" />
                    </StackPanel>
                </Grid>
            </UniformGrid>
            <GridSplitter x:Name="horizontalSplitter" Grid.Row="1" Grid.ColumnSpan="3" ShowsPreview="True" Height="3" ResizeDirection="Rows" ResizeBehavior="PreviousAndNext" HorizontalAlignment="Stretch" Background="#FFDDDDDD" />
            <GridSplitter x:Name="verticalSplitter" Grid.Column="1" Grid.RowSpan="3" ShowsPreview="True" Width="{Binding ActualHeight, ElementName=horizontalSplitter, Mode=OneWay}" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" Background="{Binding Background, ElementName=horizontalSplitter}" Visibility="Collapsed" />
        </Grid>

    </Grid>
</local:CrosswordWindowBase>
